/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package casino;

/**
 * A player uses the fibonacci sequence on every loss and resets his bet to a base amount
 * on each win. 
 * 
 * @author amaghfur
 * @since 1.0
 */
public class PlayerFibonacci extends Martingale {
    
    /** the previous bet multiplier */
    private int previous = 0;
    
    /**
     * Concrete constructor for fibonacci.
     * 
     * @param tableToPlay       table this player plays on
     * @param startingStake     this player's starting stake
     */
    public PlayerFibonacci(Table tableToPlay) {
        super(tableToPlay);
        betMultiplier = 1;
    }
            
    /**
     * Notifies this player that his bet specified on the argument is a loser and
     * by how much.
     * 
     * @param bet   losing bet
     */
    @Override
    public void lose(Bet bet) {
        
        // update according to the fibonacci sequence
        int next = betMultiplier + previous;
        previous = betMultiplier;
        betMultiplier = next;
        
        System.out.println(bet.toString() + " -> lost " + bet.loseAmount().toString());
    }
    
    /**
     * Resets this player's state. Note that it does not reset to his original stake though.
     */
    @Override
    public void reset() {
        previous = 0;
        betMultiplier = 1;
    }
}
